import { http } from '../plugs/aixos'

export function findAllComp(args = {}) {
  const url = `comp/?` + Object.entries(args).map(([key, value]) => `${key}=${value}`)
  return http.request<compModel[]>({
    url,
    method: 'GET',
  })
}

export function findComp(id: number) {
  const url = `comp/${id}`
  return http.request<compModel>({
    url,
    method: 'GET',
  })
}

export function addComp(data: compModel) {
  return http.request<compModel>({
    url: 'comp',
    method: 'POST',
    data,
  })
}

export function delComp(id: number) {
  return http.request<compModel>({
    url: `comp/${id}`,
    method: 'DELETE',
  })
}

// export function findLog(id: number) {
//   return http.request<logModel>({
//     url: `log/${id}`,
//     method: 'GET',
//   })
// }

export function updateComp(id: number, data: any) {
  return http.request<compModel>({
    url: `comp/${id}`,
    method: 'PATCH',
    data,
  })
}
